#ifndef     __FLASH_H
#define     __FLASH_H

#include <stdint.h>

namespace driver::flash {

bool Write(uint32_t addr, const void *buf, uint32_t size);

bool Erase(uint32_t addr);

bool Erase(uint32_t addr, uint32_t size);

void Read(uint32_t addr, void *buf, uint32_t size);

bool Move(uint32_t target, uint32_t src, uint32_t size);

constexpr uint32_t SectorSize = 1024 * 2;

constexpr uint32_t BootAddr = 0x08000000;
constexpr uint32_t BootSize = 16 * 1024;

constexpr uint32_t AppAddr = BootAddr + BootSize;
constexpr uint32_t AppSize = 200 * 1024;

constexpr uint32_t OtaDataAddr = AppAddr + AppSize;
constexpr uint32_t OtaDataSize = AppSize;

constexpr uint32_t OtaInfoAddr = OtaDataAddr + OtaDataSize;
constexpr uint32_t OtaInfoSize = SectorSize;

constexpr uint32_t DataAddr = OtaInfoAddr + OtaInfoSize;
constexpr uint32_t DataSize = SectorSize;


}


#endif
